{
  "properties" : { },
  "id" : "b0e6e216953b416b948505dbac556df9",
  "script" : null,
  "groupId" : "f233a970a1c5419295b8d980e50d4c51",
  "name" : "查询故障知识库类型树",
  "createTime" : 1727070972620,
  "updateTime" : 1724900466767,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "tree",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {}\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
sql = """
    SELECT * FROM ndmp_knowledge_type ORDER BY lv,SORT
"""
typeList = db.select(sql)
List result = new ArrayList();
for (item in typeList) {
    if (item.parentId == -1){
        result.add(item)
    }
}
for (item in result) {
    List children = new ArrayList();
    for (type in typeList) {
        if (item.id == type.parentId){
            children.add(type)
        }
    }
    item.children = children
}

return result